package com.example.notification;

import android.os.Bundle;
import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {

	int notificationId = 1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	public void onClick(View view) {
		displayNotification();
	}

	protected void displayNotification() {
		
		Intent intent = new Intent(this, Notification.class);
		intent.putExtra("notificationID", notificationId);
		
		PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
		
		NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
		
		android.app.Notification notification = new android.app.Notification(R.drawable.ic_launcher,"",System.currentTimeMillis());
		
		CharSequence from = "System Alarm";
		CharSequence message = "Meeting with Client";
		
		notification.setLatestEventInfo(this, from, message, pendingIntent);
		
		notification.vibrate = new long[] { 100, 250, 100, 500};
		manager.notify(notificationId, notification);
	}

}
